﻿using Klear.Library.Models;

namespace Klear.Library.Services;

/*
 * 数据测试
 */

public class Data
{
    public async Task InsertSampleDataAsync(DatabaseService databaseService)
    {
        if (!databaseService.IsInitialized)
        {
            await databaseService.InitializeAsync();
        }

        // 插入示例数据
        await databaseService.AddRecordAsync(new IncomeAndExpensesModel
        {
            Title = "Groceries",
            Amount = 150.75m,
            Category = "Food",
            Notes = "Bought weekly groceries",
        });

        await databaseService.AddRecordAsync(new IncomeAndExpensesModel
        {
            Title = "Salary",
            Amount = 3000.00m,
            Category = "Income",
            Notes = "Monthly salary received",
        });

        await databaseService.AddRecordAsync(new IncomeAndExpensesModel
        {
            Title = "Rent",
            Amount = 1200.00m,
            Category = "Housing",
            Notes = "Monthly house rent",
        });

        // 查询并打印结果
        var records = await databaseService.GetAllRecordsAsync();
        foreach (var record in records)
        {
            Console.WriteLine($"{record.Id}: {record.Title} - {record.Amount} - {record.Category} - {record.Notes} - {record.CreateTime}");
        }
    }

}
